package com.pan.admin.module.datareport.controller;

import com.pan.admin.common.core.domain.AjaxResult;
import com.pan.admin.module.channel.service.LoanChannelService;
import com.pan.admin.module.datareport.entity.StartTimeAndEndTime;
import com.pan.admin.module.datareport.service.DataReportService;
import com.pan.admin.module.loanProduct.service.LoanProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 数据报表
 *
 * @author caoxin
 */
@RestController
public class DataReportController {

    @Autowired
    private DataReportService dataReportService;
    @Autowired
    private LoanChannelService loanChannelService;
    @Autowired
    private LoanProductService loanProductService;

    /**
     * 渠道
     */
    @GetMapping("/dataReport/listLoanChannel")
    @PreAuthorize("@ss.hasPermi('dataReport:list')")
    public AjaxResult listLoanChannel(@RequestParam(required = false) String keyword) {
        return AjaxResult.success(this.loanChannelService.listLoanChannel(keyword));
    }

    /**
     * 主体
     */
    @GetMapping("/dataReport/listLoanProduct")
    @PreAuthorize("@ss.hasPermi('dataReport:list')")
    public AjaxResult listLoanProduct(@RequestParam(required = false) String keyword) {
        return AjaxResult.success(this.loanProductService.listLoanProduct(keyword));
    }

    /**
     * 进件量/推送量
     */
    @GetMapping("/dataReport/applyAndPush")
    @PreAuthorize("@ss.hasPermi('dataReport:list')")
    public AjaxResult applyAndPush(StartTimeAndEndTime startTimeAndEndTime, @RequestParam(required = false) List<Long> loanChannelId) {
        return AjaxResult.success(this.dataReportService.applyAndPush(startTimeAndEndTime, loanChannelId));
    }

    /**
     * 主体计划城市分布情况
     */
    @GetMapping("/dataReport/planCityDistributionSituation")
    @PreAuthorize("@ss.hasPermi('dataReport:list')")
    public AjaxResult planCityDistributionSituation(@RequestParam(required = false) Boolean limit) {
        return AjaxResult.success(this.dataReportService.planCityDistributionSituation(limit));
    }

    /**
     * 主体余额情况
     */
    @GetMapping("/dataReport/loanProductBalanceSituation")
    @PreAuthorize("@ss.hasPermi('dataReport:list')")
    public AjaxResult loanProductBalanceSituation(@RequestParam(required = false) Boolean desc) {
        return AjaxResult.success(this.dataReportService.loanProductBalanceSituation(desc));
    }

    /**
     * 营收数据
     */
    @GetMapping("/dataReport/revenueData")
    @PreAuthorize("@ss.hasPermi('dataReport:list')")
    public AjaxResult revenueData(StartTimeAndEndTime startTimeAndEndTime, @RequestParam(required = false) List<Long> loanChannelId, @RequestParam(required = false) List<Long> loanProductId) {
        return AjaxResult.success(this.dataReportService.revenueData(startTimeAndEndTime, loanChannelId, loanProductId));
    }

    /**
     * 充值波动情况
     */
    @GetMapping("/dataReport/recharge")
    @PreAuthorize("@ss.hasPermi('dataReport:list')")
    public AjaxResult recharge(StartTimeAndEndTime startTimeAndEndTime, @RequestParam(required = false) List<Long> loanProductId) {
        return AjaxResult.success(this.dataReportService.recharge(startTimeAndEndTime, loanProductId));
    }

    /**
     * 消耗波动情况
     */
    @GetMapping("/dataReport/amount")
    @PreAuthorize("@ss.hasPermi('dataReport:list')")
    public AjaxResult amount(StartTimeAndEndTime startTimeAndEndTime, @RequestParam(required = false) List<Long> loanProductId) {
        return AjaxResult.success(this.dataReportService.amount(startTimeAndEndTime, loanProductId));
    }

}
